package butines.game.weapon;

import butines.game.Cooldown;
import butines.game.MainTest;
import butines.game.MessageType;
import butines.game.Unit;
import butines.game.Weapon;

public class SwordWeapon extends Weapon {

	
	public SwordWeapon(int damage, int range, float waitTime) {
		super(damage, range, waitTime);
	}

	
	public void performAttack(Unit attacker) {
		Unit enemy = attacker.getEnemy();
		Cooldown cooldown = attacker.getCooldown();
		
		cooldown.setWaitTime(getWaitTime());
		cooldown.lock();
		
		if (enemy == null || enemy.isDead()) {
			return;
		}
		if (attacker.isNearToEnemy()) {
			MainTest.dispatch(MessageType.RECEIVED_DAMAGE, attacker, enemy, 0, getDamage());
		}
	}
	
}
